package com.deneme.ozveri.activities;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Button;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.deneme.ozveri.adapters.MenuItemListAdapter;
import com.deneme.ozveri.application.OzveriMenuApplicationObject;
import com.deneme.ozveri.clicklisteners.MainItemOnClickListener;
import com.deneme.ozveri.clicklisteners.TitleBarOnClickListener;
import com.deneme.ozveri.database.DBHandler;
import com.deneme.ozveri.objects.MenuItem;
import com.deneme.ozverimenu.R;

public class FrameMenuAlphaActivity extends Activity {
   
	/*ScrollViews*/
	
	ListView mainList;
	ListView subList;
	ListView orderList;
	LinearLayout menuHelperLayout;
	TextView menuHelperText;
	DBHandler dh;
	
	ArrayList<MenuItem> mainItems;
	ArrayList<MenuItem> subItems;
	
 	
	
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	
    	
    	/**************************Custon Titlebar init**********************/
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.main);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
		
		
		TitleBarOnClickListener titlebarlistener = new TitleBarOnClickListener(this);
		
		Button openOrders = (Button) findViewById(R.id.titlebar_orders_btn);
		openOrders.setOnClickListener(titlebarlistener);
		/*******************************************************************/
		
		
		dh = OzveriMenuApplicationObject.dh;
		
		mainList = (ListView) findViewById(R.id.menu_main_menulist_listview);
		subList = (ListView) findViewById(R.id.menu_sub_menulist_listview);
		orderList = (ListView) findViewById(R.id.menu_orderlist_listview);
		menuHelperLayout = (LinearLayout) findViewById(R.id.menu_helper_linear);
		menuHelperText = (TextView) findViewById(R.id.menu_helper_txt);
		
		subList.setVisibility(View.GONE);
		orderList.setVisibility(View.GONE);
		

		
		menuHelperLayout.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 80));
		menuHelperText.setText("Lutfen Sol Taraftan Ana Menu Seciniz");
		
		
		
		
		mainItems = dh.getMainMenuItems();
		
		mainList.setAdapter(new MenuItemListAdapter(mainItems, this));
		mainList.setOnItemClickListener(new MainItemOnClickListener(mainItems, dh, (Activity)this, subItems));
		
		
		
		
    }
}